#ifndef LED_H_INCLUDED
#define LED_H_INCLUDED

#include "ports.h"

namespace smasher
{

/// LED class.
/// It is important that on AVR pin has voltage in LOW state.
class LED
{
    public:
        /// New LED. Which port, which pin 0..7, isGlowingAtStart.
        LED(Port& port, uint8_t pin, bool glowingAtStart) : port(port), pin(pin)
        {
            port.setPinAsOutput(pin);
            port.setPin(pin, !glowingAtStart);
        }

        void lightOn()
        {
            port.setPin(pin, false);
        }

        void lightOff()
        {
            port.setPin(pin, true);
        }

        void toggle()
        {
            port.togglePin(pin);
        }

    private:
        Port& port;
        uint8_t pin;
};

}


#endif // LED_H_INCLUDED
